import javax.swing.border.*;

import java.text.Format;
import java.text.NumberFormat;
import java.text.ParseException;
import java.io.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
import java.text.SimpleDateFormat;
import java.text.DateFormat;
import java.util.Date;

public class Interact extends JPanel//implements ActionListener
{
	    private boolean timeA = false;
	    private boolean timeB = false;
	
        private boolean requirementOne   = false;
        private boolean requirementTwo  = false;
        private boolean requirementThree = false;
        private boolean requirementFour = false;
        private boolean requirementFive = false;
        
        private boolean outputComment = false;
        private boolean outputGeo1    = false;
        private boolean outputGeo2    = false;
        private boolean outputRes     = false;
   // Private variables
        //private final JTextArea  myTextArea;
        String test;
        //count the month
        int bcount = 0;
        int ecount = 0;
        
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd'T'HHmmss");
        
        private JTextField longitudinal = new JTextField("150"); //tag
        private JTextField latitude = new JTextField("-80");
        private JTextField decimalPlace = new JTextField("123456");
        private JTextField decimalPlaceTwo = new JTextField("123456");
        
        private boolean longTrue = false;
        private boolean declongTrue = false;
        private boolean latTrue = false;
        private boolean declatTrue = false;
        
        private String firstLongitude = null;
        private String secondLongitude = null;
        private String firstLatitude = null;
        private String secondLatitude = null;
        private String totalPosition = "GEO:";
        
        private boolean flagForTimeZoneOne = false;
        private boolean flagForTimeZoneTwo = false;
        private String  timeZone = "ZONE:";
        
        //constant String
        private String beginCal = "BEGIN:VCALENDAR";
        private String endCal   = "END:VCALENDAR";
        private String version  = "VERSION:2.0";
        private String beginE   = "BEGIN:VEVENT";
        private String endE     = "END:VEVENT";
        private String beginTime = "DTSTART:REQUIRED, Please fill out";
        private String endTime =   "DTEND:REQUIRED, Please fill out";
        private String chosenRadioButton = "CLASS:REQUIRED, Please fill out";
        private String storeComment = "COMMENT:";
        
        
        // 
        private JRadioButton publicRButton;
        private JRadioButton privateRButton;
        private JRadioButton confidentialRButton;
        private String radioButton;
        
        
        MyRadioButtonAction radioListener = new MyRadioButtonAction();
        
        
        ButtonGroup group = new ButtonGroup();
        
        
        
        // Comment variables ////////////////////
        
        
    private  JTextField myCommentArea = new JTextField(50);             
   

        private String commentString;
        ////////////////// Location and Summary JTextArea
        
        private JTextField myLocationArea = new JTextField(50);
         
        

        private String locationString = "LOCATION: REQUIRED, please fill out";
        private final JTextField mySummaryArea = new JTextField(50);
        

        private String summaryString = "SUMMARY: REQUIRED, please fill out";
        
        private JTextField myResourceField = new JTextField(50);
        private String resourceString = "RESOURCES:";
        
        
         boolean b;
         boolean leapYear;
         JPanel addCheckPanel;
        ///////////////////////
         
         private String begin_Date_Time;
         private String bMonth, bDay, bYear, bHour, bMin, bAmPm;
         
         private String end_Date_Time;
         private String eMonth, eDay, eYear, eHour, eMin, eAmPm;
         
         //////////////////////////////////////////////////
         String   firsthour;
         String   firstmin;
         String   selectDays;
         String   amPm;
         String[] beg_AmPm = {"am","pm"};
         String[] monthString = { "Jan", "Feb", "March", "April", "May", "June","July", "Aug", "Sept","Oct","Nov","Dec" }; 
         String[] dayString = {"01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31"};
         String[] thirtyDayString = {"01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30"};
         String[] leapString = {"01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29"};
         String[] beg_Min = {"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19"
             , "20", "21", "22", "23", "24", "25", "26", "27", "29","28", "30", "31", "32", "33", "34", "35", "36"
             ,"37", "38", "39", "40", "41","42", "43", "44", "45",  "46", "47", "48", "49", "50","51"
             ,"52", "53", "54", "55", "56", "57", "58", "59"};
         String[] beg_Hour = {"12","01","02","03","04","05","06","07","08","09","10","11","12"};
         String[] yearString = {"2009","2010","2011","2012","2013","2014","2015","2016","2017","2018","2019","2020","2021","2022","2023","2024","2025","2026","2027","2028","2029","2030","2031","2032","2033","2034","2035","2036","2037","2038","2039", "2040"};
     JComboBox yearList   = new JComboBox(yearString);
         JComboBox monthList  = new JComboBox(monthString);
         JComboBox dayList    = new JComboBox(dayString);
         JComboBox begin_Hour = new JComboBox(beg_Hour); 
     JComboBox begin_Min  = new JComboBox(beg_Min);
     JComboBox begin_AmPm = new JComboBox(beg_AmPm);
     
         ///////END DATE LIST ////////////////////////////
         
         JComboBox yearListTwo   = new JComboBox(yearString);
         JComboBox monthListTwo  = new JComboBox(monthString);
         JComboBox dayListTwo    = new JComboBox(dayString);
         JComboBox begin_HourTwo = new JComboBox(beg_Hour); 
     JComboBox begin_MinTwo  = new JComboBox(beg_Min);
     JComboBox begin_AmPmTwo = new JComboBox(beg_AmPm);
         
        //  Add CheckBook Variables
        
        private final JTextField myTextFieldOne   = new JTextField(7);  // check number  Integer
        private final JTextField myTextFieldTwo   = new JTextField(18); // payable to  String
    private final JTextField myTextFieldThree = new JTextField(8);  // amount   Double
        
        //  Deposit Variable
    
        private final JTextField textFieldOne     = new JTextField(8); 

        // The button will not execute unless all checked
                
        private boolean bMonthTrue     = false;
        private boolean bDayTrue       = false;
        private boolean bYearTrue      = false;
        private boolean bHourTrue      = false;
        private boolean bMinTrue       = false;
        private boolean bAmPmTrue      = false;
        
        //Add Deposit Test Variables
        
        private boolean eMonthTrue      = false;
        private boolean eDayTrue        = false;
        private boolean eYearTrue       = false;
        private boolean eHourTrue       = false;
        private boolean eMinTrue        = false;
        private boolean eAmPmTrue       = false;
        
        // Labels for begin date end date
        
        private final JLabel myLabelTwo   = new JLabel("Month");
    private final JLabel myLabelThree = new JLabel("Day");
    private final JLabel myLabelFour  = new JLabel("Year");
    private final JLabel mybHourLabel = new JLabel("Start Time");
    private final JLabel mybMinLabel  = new JLabel(":");
    private final JLabel mybAmPMLabel = new JLabel("am/pm");
        
    // End Date
    
        // Add CheckBook Button
        
        private final JButton   myButton    = new JButton("Submit");      // button submit begin Date & Time
        
        // END DATE LABEL
        
        private final JLabel  endLabelm     = new JLabel ("Month");
        private final JLabel  endLabeld     = new JLabel ("Day");
        private final JLabel  endLabely   = new JLabel ("Year");
        private final JLabel  endHourLabel = new JLabel("End Time");
        private final JLabel  endMinLabel  = new JLabel(":");
        private final JLabel  endAmPMLabel = new JLabel("am/pm");

 //Deposit Button  
        
        private final JButton myButtonOne  = new JButton("Submit");
        // Add History, Balance, Deposit Buttons

        private final JButton   buttonOne   = new JButton("View Input information");
        private final JButton   buttonTwo   = new JButton("CREATE .ICS FILE");
        //private final JButton   buttonThree = new JButton("???");

   // save and exit
        private final  JButton exitButton = new JButton("Exit");
        private final  JButton saveButton = new JButton("Save");
        private final  JButton helpButton = new JButton("Help");
        
    private final  File    file       = new File("check.dat");
        private final  File    fileTwo    = new File("deposit.dat");

   //Remove Check

    private final  JButton    commentButton = new JButton("Submit");

    private final  JTextField field        = new JTextField(100);

    private int      removeCheckNumber;
        
        private int      removeCount;
        
        private boolean  removeTrue = false;
        
         // Add Check number array
        
        private int[] checkNo  = new int[100];

        ///////////////////////////////////////////////////////
        
        private final JLabel    myLabel    = new JLabel();
        
        private final JTextArea myTextArea = new JTextArea(30, 55);
        
        //private String[] monthString       = new String[12];
        
        //private JComboBox monthList        = new JComboBox(monthString);
        
        //Object variable name////////////////////////////////////////////////
        
//      private MyCheckTextAction    checkNum              = new MyCheckTextAction();
        
        private MyCheckButtonAction  click                 = new MyCheckButtonAction();    //  Add Check Button
        
        private MyCheckButtonActionTwo  click_Two          = new MyCheckButtonActionTwo();
        
        private MyResultButtonAction list                  = new MyResultButtonAction();   //check,deposit, balance history
        
//      private MyDepositButton      depClick              = new MyDepositButton();
        
        private MySaveButtonAction   saveExit              = new MySaveButtonAction();
        
        private MyEraseTextField     eraseCheckNumber      = new  MyEraseTextField();
        
        //private MyEraseButtonAction  eraseButtonAction     = new  MyEraseButtonAction();
        
                
///////////////checkbook variables///////////////////////////////////////////// 
        
//      private int    checkNumber; 
        
        private double amount, totalCheckAmount;
        
/////////COUNTERS
        
    private int buttonCheckNumberCount;
        
        private int checkNumberCount;
        
        private int checkCount;
        
        private int buttonDepositNumberCount;
        
         

////Check Arrays////////////////////////////

    private int[]       storeCheckNumber      = new int[100];
        private String[][]  storeCheckInformation = new String[100][100];
    private double[]    storeCheckAmount      = new double[100];

////Deposit Arrays////////////////////////////////////////////////////

    private double[]   storeDepositAmount      = new double[100];
    private String[][] storeDepositInformation = new String[100][100];
                                        
////////////deposit variables///////////////////////////////////////

    private String monthTwo, dayTwo, yearTwo; 
        private double amountTwo, totalDepositAmount;
        
///////////////////////////////////////////////////////////////////////////////////////////
                    
   // Constructor - create the Panel
   
        public Interact() 
        {     
                 //initializing count  (should both be the same)
                 
                 checkNumberCount       = 0;
                 buttonCheckNumberCount = 0;
                 checkCount             = 0;
                               
            myTextArea.setEditable(false);
        myTextArea.setCaretPosition(myTextArea.getDocument().getLength());  //force scroll to the bottom of the screen
                JScrollPane scrollPane = new JScrollPane(myTextArea);                            
                
/////////////////////////////////////////////////////////////////////////

        boolean exist    = file.exists();                //check to see if binary.dat exist
                boolean existTwo = fileTwo.exists();
                  
                  if(exist  || existTwo)   //checking for binary.dat (checking transaction information) 
                  { 
                     if(exist)
                          {
                           try
                           {     
                                 DataInputStream instr = new DataInputStream(new BufferedInputStream(new FileInputStream( file  ) ) );
                                 
                                         
                                         totalCheckAmount       = instr.readDouble();
                                         buttonCheckNumberCount = instr.readInt();
                        
                                         for (int m = 0; m < buttonCheckNumberCount; m++) 
                                                {
                                                        storeCheckNumber[m]          =  instr.readInt    ();
                                                storeCheckInformation[m][1]  =  instr.readUTF    ();
                                storeCheckInformation[m][2]  =  instr.readUTF    ();
                                        storeCheckInformation[m][3]  =  instr.readUTF    ();
                                        storeCheckInformation[m][4]  =  instr.readUTF    ();
                                    storeCheckAmount[m]          =  instr.readDouble ();
                        }  
               instr.close();
               }
               catch ( IOException iox )
               {
                    myTextArea.append("Problem reading " + file );
               }
            }  //end of if(exist) statement

                                                                
                                if(existTwo)
                                 {  
                                        try
                                        {      
                                                        DataInputStream instrTwo = new DataInputStream(new BufferedInputStream(new FileInputStream( fileTwo  ) ) );

                                    totalDepositAmount            = instrTwo.readDouble  ();         
                                                    buttonDepositNumberCount      = instrTwo.readInt     ();
                         
                                        for (int k = 0; k < buttonDepositNumberCount; k++) 
                                    {
                            storeDepositInformation[k][1] =  instrTwo.readUTF    ();
                                storeDepositInformation[k][2] =  instrTwo.readUTF    ();
                                        storeDepositInformation[k][3] =  instrTwo.readUTF    ();
                                    storeDepositAmount[k]         =  instrTwo.readDouble ();
                            }
                                                              
                    instrTwo.close();
                   }
                   catch ( IOException iox )
                    {
                         myTextArea.append("Problem reading " + fileTwo );

                    }
              }//end of if(existTwo)
                                                
                                  
                                  
          }//end of if(exist || existTwo)

                        publicRButton       = new JRadioButton("public");
                        privateRButton      = new JRadioButton("private");
                        confidentialRButton = new JRadioButton("confidential");        
                        
                        
                        group.add(publicRButton);
                        group.add(privateRButton);
                        group.add(confidentialRButton);
                        
                        publicRButton.addActionListener(radioListener);      
                        privateRButton.addActionListener(radioListener);     
                        confidentialRButton.addActionListener(radioListener);       
                                 
  //////Add Check Text Listeners///////////////////////////////////////////////
  
   /*
                    
                 myTextFieldOne.addActionListener  (textListener);

         myTextFieldTwo.addActionListener  (textListener);
                        
                 myTextFieldThree.addActionListener(textListener);
*/
///////Add Button Listeners///////////////add checks/////////////////////////////////////

             myButton.addActionListener(click);

/////////Add  3 Buttons Listener/////////deposit, balance, check history///////////////////// 
         
                 buttonOne.addActionListener(list);
                 buttonTwo.addActionListener(new WriteToFile());
  //       buttonThree.addActionListener(list);

 ///////////////////deposit button action//////////////////////////////////

         MyDepositTextAction        depAmt   = new MyDepositTextAction(); 
             
         myButtonOne.addActionListener(click_Two);
                 textFieldOne.addActionListener(depAmt);

///////////remove Listener////////////////////////////////////////////

                

                 
                 
         field.addActionListener(eraseCheckNumber);
             myCommentArea.addActionListener(new CommentButtonAction());
                                
//////////////////////save button listener//////////////////////////////////////////////
                    
                 helpButton.addActionListener(saveExit);
                   
                 exitButton.addActionListener(saveExit);
                        
                 saveButton.addActionListener(saveExit);
                 
                 ///////////////////////////////////
        
                 //myCommentArea.setColumns(10);
                // myCommentArea.setLineWrap (true);

                  //  myCommentArea.setCaretPosition(0);  //force scroll to the bottom of the screen
                        //JScrollPane scrollPaneOne = new JScrollPane(myCommentArea);   
                 
//////////////////////PLEASE  ENTER BEGIN DATE AND TIME/////////////////////////////////////////  
 
         monthList.setEditable(false);                        // by default set to false, for this reason, I did not include this to the others.
                 monthList.setSelectedIndex(0);                       // initially selection in the array
                 monthList.setEnabled(false);  
        //       monthList.setSelectedItem(null);
         
                 //selectDays = "00";
                 monthList.addActionListener(new MyCheckAction());          
                 
         dayList.setSelectedIndex(0);                       //Begin selection here
             dayList.addActionListener(new MyCheckAction());
             dayList.setEnabled(false);
         //    dayList.setSelectedItem(null);
             
         yearList.setSelectedIndex(0);
         yearList.addActionListener(new MyCheckAction());
      //   yearList.setSelectedItem(null);

      //  JComboBox begin_Hour = new JComboBox(beg_Hour);
         begin_Hour.setSelectedIndex(0);
         begin_Hour.addActionListener(new MyCheckAction());
      //  begin_Hour.setSelectedItem(null);
                 
      //   JComboBox begin_Min = new JComboBox(beg_Min);
         begin_Min.setSelectedIndex(0);
         begin_Min.addActionListener(new MyCheckAction());
     //    begin_Min.setSelectedItem(null);
         
         String[] beg_AmPm = {"am","pm"};
     //    JComboBox begin_AmPm = new JComboBox(beg_AmPm);
         //begin_AmPm.setSelectedIndex(0);
          begin_AmPm.setEnabled(true);
         begin_AmPm.addActionListener(new MyCheckAction());
     //    begin_AmPm.setSelectedItem(null);
          
//////////////////////////END DATE////////////////////////////////////////
          
         monthListTwo.setEditable(false);                        // by default set to false, for this reason, I did not include this to the others.
                 monthListTwo.setSelectedIndex(0);                       // initially selection in the array
                 monthListTwo.setEnabled(false);
//               monthListTwo.setSelectedItem(null);
                 
                 monthListTwo.addActionListener(new MyCheckActionTwo());          
                
        
         dayListTwo.setSelectedIndex(0);    //Begin selection here
             dayListTwo.addActionListener(new MyCheckActionTwo());
             dayListTwo.setEnabled(false);
//           dayListTwo.setSelectedItem(null);
             
         yearListTwo.setSelectedIndex(0);
         yearListTwo.addActionListener(new MyCheckActionTwo());
         //yearListTwo.setSelectedItem(null);
         
         
         begin_HourTwo.setSelectedIndex(0);
         begin_HourTwo.addActionListener(new MyCheckActionTwo());
  //       begin_HourTwo.setSelectedItem(null);
         
         begin_MinTwo.setSelectedIndex(0);
         begin_MinTwo.addActionListener(new MyCheckActionTwo());
   //      begin_MinTwo.setSelectedItem(null);
         
         begin_AmPmTwo.setSelectedIndex(0);
         begin_AmPmTwo.addActionListener(new MyCheckActionTwo());   
   //      begin_AmPmTwo.setSelectedItem(null);
         
                 MyDepositList depositListener = new MyDepositList();
                  

///checkbook title panel//////////////////////////////////////////////////////

         JPanel addChk = new JPanel();
                 addChk.setPreferredSize( new Dimension(1000,20));
         addChk.setBackground(Color.green);
         JLabel checkTitle = new JLabel("Please Enter Begin Date and Time");
                 addChk.add(checkTitle);    
                                
/////TEXT AREA///////////////////////////////////////////////////////////////////
   
             JPanel screen = new JPanel();
                 screen.add(scrollPane);
                 //screen.add(myTextArea);
                 //screen.add(scrollPane, c);
                 
//////ADD CheckBook Panel///////////////////////////////////////////////  
           
             JPanel addCheckPanel =  new JPanel();
                 addCheckPanel.setPreferredSize( new Dimension(1000,35));
                 addCheckPanel.setBackground(Color.green);
                 Border mb1 = BorderFactory.createMatteBorder(1,1,1,1,Color.black);
                 addCheckPanel.setBorder(mb1);


                 addCheckPanel.add(myLabelFour);       //Check year
                 addCheckPanel.add(yearList);      
                 
                 addCheckPanel.add(myLabelTwo);        //Check month
                 addCheckPanel.add(monthList);

                 addCheckPanel.add(myLabelThree);      //Check day
                 addCheckPanel.add(dayList); 
                 
                 addCheckPanel.add(mybHourLabel);      //label
                 addCheckPanel.add(begin_Hour);
                 
                 addCheckPanel.add(mybMinLabel);      //label
                 addCheckPanel.add(begin_Min);
                 
                 addCheckPanel.add(mybAmPMLabel);     //label
                 addCheckPanel.add(begin_AmPm);
                 
                 addCheckPanel.add(myButton);          //Check Button
 //////////////////////position
                 JPanel positionPanelZero = new JPanel();
                 positionPanelZero.setPreferredSize( new Dimension(1000,25));
                 positionPanelZero.setBackground(Color.lightGray);
                 JLabel positionTitle = new JLabel("POSITION:");
                 positionPanelZero.add(positionTitle);
                 Border mb7 = BorderFactory.createMatteBorder(1,1,0,1,Color.black);
                 positionPanelZero.setBorder(mb7);

                 
                 JPanel positionPanel = new JPanel();
                 JPanel positionPanelTwo = new JPanel();
         JLabel longitudinalName = new JLabel("Longitude");
         JLabel longitudinalrange = new JLabel("(from -180 to 180)"); 
         JLabel latitudeName = new JLabel("           Latitude");
         JLabel latituderange = new JLabel("(from -90 to 90)");
                 positionPanel.setPreferredSize( new Dimension(1000,35));
                 positionPanel.setBackground(Color.lightGray);
                 JLabel dlong  = new JLabel("(up to six places after the decimal, ex.  xxx.000000)");
                 JLabel dot    = new JLabel (".");
                 JLabel dotTwo = new JLabel(".");
                 JLabel dlongTwo = new JLabel("(up to six places after the decimal, ex. xx.000000)");
                 Border mb8 = BorderFactory.createMatteBorder(0,1,0,1,Color.black);
                 positionPanel.setBorder(mb8);
                 positionPanel.add(longitudinalName);
                 positionPanel.add(longitudinalrange);
                 positionPanel.add(longitudinal);
                 positionPanel.add(dot);
                 positionPanel.add(decimalPlaceTwo);
             positionPanel.add(dlong);
             
             latitude.addActionListener(new MyPositionOne());
             decimalPlace.addActionListener(new MyPositionOne());
             
             
             positionPanelTwo.setPreferredSize( new Dimension(1000,35));
                 positionPanelTwo.setBackground(Color.lightGray);
                 
                 positionPanelTwo.add(latitudeName);
                 positionPanelTwo.add(latituderange);
                 positionPanelTwo.add(latitude);
                 positionPanelTwo.add(dotTwo);
                 positionPanelTwo.add(decimalPlace);
             positionPanelTwo.add(dlongTwo);
             Border mb9 = BorderFactory.createMatteBorder(0,1,1,1,Color.black);
             positionPanelTwo.setBorder(mb9);
             longitudinal.addActionListener(new MyPositionTwo());
             decimalPlaceTwo.addActionListener(new MyPositionTwo());
                         
//////Location panel////////////////////////////////////////////////////////////////

         JPanel commentPanel = new JPanel();
                 JLabel commentLabel = new JLabel("Location: ");
                 commentPanel.setBackground(Color.lightGray);             //color and dimension
                 commentPanel.setPreferredSize( new Dimension(1000,30));
                 Border mb3 = BorderFactory.createMatteBorder(1,1,1,1,Color.black);
                 commentPanel.setBorder(mb3);
                 commentPanel.add(commentLabel);      //add Label
                 commentPanel.add(myLocationArea);
                 myLocationArea.addActionListener(new MyLocationTextField());
                
                 
                 
                 
                         
/////Summary Panel/////////////////////////////////////////////////////////////////////////////   
                
                 
                 
                 JPanel summaryPanel = new JPanel();
                 JLabel summaryLabel  = new JLabel("Summary: ");
                 summaryPanel.add(summaryLabel);
                 Border mb4 = BorderFactory.createMatteBorder(1,1,1,1,Color.black);
                 summaryPanel.setBorder(mb4);
                 summaryPanel.add(mySummaryArea);
                 summaryPanel.setBackground(Color.lightGray);  
                 summaryPanel.setPreferredSize( new Dimension(1000,30));
                 mySummaryArea.addActionListener(new  MySummaryTextField() );
                
                 
///Resources Panel
                 
                 JPanel resourcePanel = new JPanel();
                 JLabel resourceLabel  = new JLabel("Resources: ");
                 resourcePanel.add(resourceLabel);
                 resourcePanel.add(myResourceField);
                 resourcePanel.setBackground(Color.lightGray);  
                 resourcePanel.setPreferredSize( new Dimension(1000,30));
                 myResourceField.addActionListener(new  MyResourceTextField()); 
                 Border mb5 = BorderFactory.createMatteBorder(1,1,1,1,Color.black);

                 resourcePanel.setBorder(mb5);
/////Comment Panel//////////////                 
                 
                 JPanel     CommentPanel = new JPanel();
                 JLabel     text        = new JLabel ("Comment:");
                               
                 
                 CommentPanel.setBackground(Color.lightGray);
                 CommentPanel.setPreferredSize(new Dimension(1000,30));
                 Border mb6 = BorderFactory.createMatteBorder(1,1,1,1,Color.black);
CommentPanel.setBorder(mb6);
                 CommentPanel.add(text);
                 CommentPanel.add(myCommentArea);
                 CommentPanel.add(Box.createRigidArea (new Dimension(0,20)));
                 
                
//////END TIME LABEL//////////////////////////////////////////////////////////////////

         JPanel depositPanel = new JPanel();
                 JLabel depositLabel = new JLabel("Please Enter End Date and Time");
 
                 depositPanel.setPreferredSize(new Dimension(1000,20));
         depositPanel.setBackground(Color.green); 
               
                 depositPanel.add(depositLabel);                 
                 
/////Add Money////////////////////////////////////////////////////////////////////////////////
      
                 JPanel addDeposit = new JPanel();
                 Border mb2 = BorderFactory.createMatteBorder(1,1,1,1,Color.black);
                 addDeposit.setBorder(mb2);

                 addDeposit.setPreferredSize( new Dimension(1000,35));
         addDeposit.setBackground(Color.green); 
                                
         addDeposit.add(endLabely);            //string year
         
                 addDeposit.add(yearListTwo);          //input list

         
                 addDeposit.add(endLabelm);            //string month
                   
         addDeposit.add(monthListTwo);         //input list
        
                 addDeposit.add(endLabeld);            //string day
                   
                 addDeposit.add(dayListTwo);           //input list     

                 
                 addDeposit.add(endHourLabel);         //string month
                   
         addDeposit.add(begin_HourTwo);       //input list
        
                 addDeposit.add(endMinLabel);         //string day
                   
                 addDeposit.add(begin_MinTwo);        //input list  
                 
                 
                
         addDeposit.add(endAmPMLabel);        //amount

                 addDeposit.add(begin_AmPmTwo);       //text field
        
                                
                 addDeposit.add(myButtonOne);

//////CHECK RECORD/////////////////////////////////////////////////////////////////
        
                 JPanel createICS  = new JPanel();
                                                
         createICS.setPreferredSize( new Dimension(1000,35));
                 createICS.setBackground(Color.lightGray);     
                 
                 createICS.add(buttonOne);
                 createICS.add(buttonTwo);
                // checkRecord.add(buttonThree);
                 
////SAVEEXIT//////////////////////////////////////////////////////////////////////////////

     JPanel saveExit = new JPanel();
                     
        
                 saveExit.setPreferredSize( new Dimension(1000,35));
         saveExit.setBackground(Color.black);
                
                 saveExit.add(helpButton);
                 saveExit.add(saveButton);               
                 saveExit.add(exitButton);
                        
///PRIMARY PAGE/////////////////////////////////////////////////////////////////////////////     

      
                 
                 JPanel mainWindow = new JPanel();
                 mainWindow.setPreferredSize(new Dimension(1000,1000));
                 Border mb = BorderFactory.createMatteBorder(2,2,2,2,Color.black);
                 mainWindow.setBorder(mb);
                 mainWindow.setBackground(Color.lightGray);
                 mainWindow.add(screen);
                 mainWindow.add(addChk);    //title
                 mainWindow.add(addCheckPanel);

                 mainWindow.add(depositPanel);  //title
                 mainWindow.add(addDeposit);
                 
                 mainWindow.add(commentPanel );  //title
                 mainWindow.add(summaryPanel);
                 mainWindow.add(resourcePanel);
                 mainWindow.add(CommentPanel);
                 mainWindow.add(positionPanelZero);
                 mainWindow.add(positionPanel);
                 mainWindow.add(positionPanelTwo);
                 mainWindow.add(publicRButton);
                 mainWindow.add(privateRButton);
                 mainWindow.add(confidentialRButton);
                 mainWindow.add(createICS);   //title
                // add(saveExit);
                 
                 add(mainWindow);

        }  //////////////////////////////// END OF CONSTRUCTOR  
   
                
   //////////////// Event Handler///////////////////////////////////////////////////////// 
        
        //////////// JComboBox Listener ///////CHECK DATES/////////////////////////////////////
        
        public class MyCheckAction implements ActionListener   //Check dates
        {
                  
                public void actionPerformed(ActionEvent event)
                {
        //  When an event occurs, get the text in myTextField and display it in myLabel
        //  myLabel.setText("You entered " + myTextFieldOne.getText());
                  //  String text = myTextFieldOne.getText();
                         
                  JComboBox cb = (JComboBox)event.getSource();
                         
          String data = (String)cb.getSelectedItem();
                                         
        //  String cb = monthList.getSelectedItem();
          
          
          if(cb.getItemCount() == 12)
                          {  
                             bMonth = data; 
                                 myTextArea.append("Month entered " + "\"" + bMonth +"\"" + "\n");
                         bMonthTrue = true;     
                         dayList.setEnabled(true);
                         for(int j = 0; j < 12; j++)
                         {
                                 if(data == cb.getItemAt(j) )
                                 {
                                bcount = j+1;
                                j = 12;
                                //System.out.print(bcount+1);
                                 }               
                         }
                         int i = 1;
                         if(bMonth == "Feb")
                         {
                                 
                                 if(leapYear == true)
                                 {
                                         while(dayList.getItemCount() != 28)
                                         {
                                             dayList.removeItemAt((dayList.getItemCount()) - i); 
                                         }
                                 }
                                 else
                                 {
                                         while(dayList.getItemCount() != 29)    //items in array
                                         {
                                                 dayList.removeItemAt((dayList.getItemCount()) - i);    // array index  
                                         }
                                 }
                         }
                         
                         //Trying to make the days to thirty
                         if(bMonth == "April" || bMonth == "June" || bMonth == "Sept" || bMonth == "Oct" || bMonth == "Nov")
                         {
                                 while(dayList.getItemCount() <= 30)    //items in array
                                 {
                                        dayList.addItem(Integer.toString(dayList.getItemCount() + i));    // array index  
                                 }
                                 while(dayList.getItemCount() > 30)    //items in array
                                 {
                                    dayList.removeItemAt((dayList.getItemCount()) - i);    // array index  
                                 } 
                         }
                         if(bMonth == "Jan" || bMonth == "March" || bMonth == "May" || bMonth == "July" || bMonth == "Aug" || bMonth == "Oct" || bMonth == "Dec")
                         {
                                 while(dayList.getItemCount() < 31)    //items in array
                                 {
                                     dayList.addItem(Integer.toString(dayList.getItemCount() + i));    // array index  
                                 }
                         }
                          }  
                         if(cb.getItemCount() == 28 || cb.getItemCount() == 29 || cb.getItemCount() == 30 || cb.getItemCount() == 31)
                          {  
                             bDay = data;
                                 myTextArea.append("Day entered " +"\"" + bDay + "\"" + "\n");
                             bDayTrue = true;
                          }
                         if(cb.getItemCount() == 32)
                 {  
                             bYear = data; 
                                 myTextArea.append("Year entered "  + "\"" + bYear + "\"" + "\n");
                         bYearTrue = true;
                         monthList.setEnabled(true);
                         if(Integer.parseInt(data)%4 != 0)
                                 leapYear = false;
                         else
                                 leapYear = true;
                         }
                         
                         if(cb.getItemCount() == 13)    // hour
                     {  
                                     bHour = data; 
                                         myTextArea.append("Begin Hour entered "  + "\"" + bHour + "\"" + "\n");
                                 bHourTrue = true;
                         }
                         if(cb.getItemCount() == 60)    // hour
                     {  
                                     bMin = data; 
                                         myTextArea.append("Begin Min entered "  + "\"" + bMin + "\"" + "\n");
                                 bMinTrue = true;           
                        }
                         if(cb.getItemCount() == 2)
                          {  
                             bAmPm = data;
                                 myTextArea.append("You entered " +"\"" + bAmPm + "\"" + "\n");
                             bAmPmTrue = true;  
                      }
                }
        }
        public class MyCheckActionTwo implements ActionListener   //Check dates
        {         
                public void actionPerformed(ActionEvent event)
                {
        //  When an event occurs, get the text in myTextField and display it in myLabel
        //  myLabel.setText("You entered " + myTextFieldOne.getText());
                  //  String text = myTextFieldOne.getText();
                         
                  JComboBox cb = (JComboBox)event.getSource();
                         
          String data = (String)cb.getSelectedItem();
                                         
        //  String cb = bmonthList.getSelectedItem();
          if(cb.getItemCount() == 12)
                          {  
                             eMonth = data; //bra
                                 myTextArea.append("You typed: " + "\"" + eMonth +"\"" + "\n");
                         eMonthTrue = true;     
                         dayListTwo.setEnabled(true);
                         for(int j = 0; j < 12; j++)
                         {
                                 if(data == cb.getItemAt(j) )
                                 {
                                ecount = j+1;
                                j = 12;
                                //System.out.print(ecount+1);
                                 }               
                         }
                         
                         
                         
                         int i = 1;
                         if(eMonth == "Feb")
                         {
                                 
                                 if(leapYear == true)
                                 {
                                         while(dayListTwo.getItemCount() != 28)
                                         {
                                             dayListTwo.removeItemAt((dayListTwo.getItemCount()) - i); 
                                         }
                                 }
                                 else
                                 {
                                         while(dayListTwo.getItemCount() != 29)    //items in array
                                         {
                                                 dayListTwo.removeItemAt((dayListTwo.getItemCount()) - i);    // array index  
                                         }
                                 }
                         }               
                         //Trying to make the days to thirty
                         if(eMonth == "April" || eMonth == "June" || eMonth == "Sept" || eMonth == "Oct" || eMonth == "Nov")
                         {
                                 while(dayListTwo.getItemCount() <= 30)    //items in array
                                 {
                                        dayListTwo.addItem(Integer.toString(dayListTwo.getItemCount() + i));    // array index  
                                 }
                                 while(dayListTwo.getItemCount() > 30)    //items in array
                                 {       
                                    dayListTwo.removeItemAt((dayListTwo.getItemCount()) - i);    // array index  
                                 } 
                         }
                         if(eMonth == "Jan" || eMonth == "March" || eMonth == "May" || eMonth == "July" || eMonth == "Aug" || eMonth == "Oct" || eMonth == "Dec")
                         {
                                 while(dayListTwo.getItemCount() < 31)    //items in array
                                 {
                                     dayListTwo.addItem(Integer.toString(dayListTwo.getItemCount() + i));    // array index  
                                 }
                         }
                          }  
                         if(cb.getItemCount() == 28 || cb.getItemCount() == 29 || cb.getItemCount() == 30 || cb.getItemCount() == 31)
                          {  
                             eDay = data;
                                 myTextArea.append("Day entered " +"\"" + eDay + "\"" + "\n");
                             eDayTrue = true;
                          }
                         if(cb.getItemCount() == 32)
                 {  
                             eYear = data; 
                                 myTextArea.append("Year entered "  + "\"" + eYear + "\"" + "\n");
                         eYearTrue = true;
                         monthListTwo.setEnabled(true);
                         if(Integer.parseInt(data)%4 != 0)
                                 leapYear = false;
                         else
                                 leapYear = true;
                         }
                         if(cb.getItemCount() == 13)    // hour
                     {  
                                     eHour = data; 
                                         myTextArea.append("End Hour entered "  + "\"" + eHour + "\"" + "\n");
                                 eHourTrue = true;          
                         }
                         if(cb.getItemCount() == 60)    // hour
                     {  
                                     eMin = data; 
                                         myTextArea.append("End Min entered "  + "\"" + eMin + "\"" + "\n");
                                 eMinTrue = true;         
                         }
                         if(cb.getItemCount() == 2)
                          {  
                             eAmPm = data;
                                 myTextArea.append("You entered " +"\"" + eAmPm + "\"" + "\n");
                             eAmPmTrue = true;   
                      }
                }
        }       
        public class MyCheckButtonAction implements ActionListener
        {                               
                public void actionPerformed(ActionEvent event)
                {   
                    if(bMonthTrue && bDayTrue && bYearTrue && bHourTrue && bMinTrue && bAmPmTrue)
                    {                   
                                 bMonthTrue   = false;
                                 bDayTrue     = false; 
                                 bYearTrue    = false; 
                                 bHourTrue    = false;
                                 bMinTrue     = false;
                                 bAmPmTrue    = false;
                                  
                                 
                                 monthList.setEnabled(false); 
                                 dayList.setEnabled(false); 
        
                                 myTextFieldOne.setText("");                             
                                 myTextFieldTwo.setText("");
                                 myTextFieldThree.setText(""); 
                                 
                                 int int_Hours  = Integer.parseInt(bHour);
                                 int convert_To_Military_Hour;
                                 
                                 
                                 if(bAmPm == "am")
                                 {
                                         if(Integer.parseInt(bHour) < 10)
                                         {       
                                                 bHour = bHour;
                                         }               
                                 }
                                 else
                                 {
                                    int_Hours = int_Hours + 12;
                                    bHour = Integer.toString(int_Hours);
                                 }
                                 
                                 if(bcount < 10)
                                         bMonth = "0" + Integer.toString(bcount);
                                 else
                                         bMonth = "Integer.toString(bcount)";
                
                                 begin_Date_Time = bYear + bMonth + bDay + "T" +  bHour + bMin + "00";
                                 flagForTimeZoneOne = true;
                                 Date now = new Date();
                                 SimpleDateFormat  format = new SimpleDateFormat("z"); 
                                 String newF = format.format(now);
                                 timeZone = "ZONE: " + newF;
                                 beginTime = "DTSTART;TZID="+newF +":"+ begin_Date_Time;
                                 requirementThree = true;
                          /*   
                                 
                                 if(timeB == true)
                                 {
                                	 if((eYear > bYear)
                                	 {
                                	 
                                	 
                                	     pass
                                	 
                                	 } else if ( eYear < byear)
                                	 {
                                	 
                                	   flunk
                                	 }
                                	else if (eYear == bYear)
                                	{
                                	     if(emonth > bmonth)
                                	        {
                                	           pass
                                	           }
                                	           else if (emonth < bmonth)
                                	                {
                                	                
                                	                   flunk;
                                	                }
                                	                else if (emonth == bmonth)
                                	                {
                                	                     if (edays > bdays)
                                	                         pass
                                	                         else if(edays < bdays)
                                	                           flunk
                                	                           elseif (edays == bdays)
                                	                           {
                                	                               if(ehour > b hour)
                                	                                  pass
                                	                                  else if(ehour < bhour)
                                	                                     fail
                                	                                     else if(ehour == bhour)
                                	                                     {
                                	                                        if(emin > bmin)
                                	                                        pass
                                	                                        if(emin < bmin
                                	                                        fluck
                                	                                        if emin == bmin
                                	                                           date and time are the same.
                                	                                     
                                	                                     
                                	                                     }
                                	                                 
                                	                                  
                                	                           
                                	                           }
                                	                
                                	                
                                	                }
                                	     
                                	
                                	
                                	}
                                	 
                                	 
                                	 
                                	      if(  pass
                                	        else if(eYear < bYear)
                                	              fail
                                	              
                                	        else if(eMonth > bMonth)
                                	                    pass + bDay + "T" +  bHour + bMin + "00";
                                	 
                                	 
                                	 
                                	 eYear + eMonth + eDay + "T" +  eHour + eMin + "00";
                                 }
                                 
                                 
                                 
                                 
                                 
                                 
                                 
                                 
                                 
                                 
                            */     
                                 
                                 
                                 
                             myTextArea.append(begin_Date_Time + "\n"  );
                            
                             
                /*           try { 
                             String dtStart = "20101015T092737Z";  
                            Date now = new Date();
                            Date date = format.parse(dtStart);
                              //TZID: HST
                                  
                                 String nownow = now.toString();
                                 System.out.println(date);
                                 System.out.println(nownow);
                                 test = date.toString();
                                 System.out.println(test);
                               //  SimpleDateFormat  format = new SimpleDateFormat("yyyyMMdd'T'HHmmss'z'");
                              //   String newF = format.format(test);
                                 System.out.println(test);
                                 Date now1 = new Date();
                                            String datetimeStr = now1.toString();
                                            SimpleDateFormat  format = new SimpleDateFormat("z:yyyyMMdd'T'HHmmss"); 
                                                String newF = format.format(now1);
                                                String newF1 = format.format(date);
                                                System.out.println(newF + " " + newF1);
                                 
                             } catch (ParseException e) {  
                                 // TODO Auto-generated catch block  
                                 e.printStackTrace();  }
                            
                                
                                // System.out.println(hello);
                        */       
                /*       
                                 storeCheckNumber[buttonCheckNumberCount] = checkNumber;
                     storeCheckAmount[buttonCheckNumberCount] = amount;
                                        
                                 storeCheckInformation[buttonCheckNumberCount][1] = bMonth;
                                 storeCheckInformation[buttonCheckNumberCount][2] = bDay;
                                 storeCheckInformation[buttonCheckNumberCount][3] = bYear;
                        */      
                                 /*
                                 NumberFormat nf = NumberFormat.getCurrencyInstance();
                 myTextArea.append("\nBegin Date & Time Entered:" + "\n");
                   
                             myTextArea.append( "\n\n" + "If this information is correct, please click on save. " +  "\n"  );
                                 */
                                
                                         
               }   
                   else
                   {  
                             myTextArea.append("\n\n" + "You did not enter or clicked on all the fields." + "\n");
                   }
                                
                }       //end of actionPerformed method         
        
        
        }//end of class MyCheckButtonAction
        
        public class MyCheckButtonActionTwo implements ActionListener
        {                               
                public void actionPerformed(ActionEvent event)
                {   
                    if(eMonthTrue && eDayTrue && eYearTrue && eHourTrue && eMinTrue && eAmPmTrue)
                    {                   
                                 eMonthTrue   = false;
                                 eDayTrue     = false; 
                                 eYearTrue    = false; 
                                 eHourTrue    = false;
                                 eMinTrue     = false;
                                 eAmPmTrue    = false;
                                 
                                 monthListTwo.setEnabled(false); 
                                 dayListTwo.setEnabled(false); 
        
                                 myTextFieldOne.setText("");                             
                                 myTextFieldTwo.setText("");
                                 myTextFieldThree.setText(""); 
                                 
                                 int int_Hours  = Integer.parseInt(eHour);
                                 int convert_To_Military_Hour;
                                 
                                 if(eAmPm == "am")
                                 {
                                         if(Integer.parseInt(eHour) < 10)
                                         {       
                                                 eHour = eHour;
                                         }               
                                 }
                                 else
                                 {
                                    int_Hours = int_Hours + 12;
                                    eHour = Integer.toString(int_Hours);
                                 }
                                 
                                 if(bcount < 10)
                                         eMonth = "0" + Integer.toString(ecount);
                                 else
                                         eMonth = "Integer.toString(ecount)";
                        
                                 end_Date_Time = eYear + eMonth + eDay + "T" +  eHour + eMin + "00";
                             flagForTimeZoneTwo = true;
                             Date now = new Date();
                                 SimpleDateFormat  format = new SimpleDateFormat("z"); 
                                 String newF = format.format(now);
                                 timeZone = "ZONE: " + newF;
                             endTime =   "DTEND;TZID="+ newF+":" + end_Date_Time;
                                 requirementFour = true;
                                 myTextArea.append(end_Date_Time + "\n"  );
                                                                
                                         
               }   
                   else
                   {  
                             myTextArea.append("\n\n" + "You did not enter or clicked on all the fields." + "\n");
                   }
                                
                }       //end of actionPerformed method         
        
        
        }//end of class MyCheckButtonAction
        
        public class MyPositionOne  implements ActionListener
        {
                public void actionPerformed(ActionEvent event)
                {
                        int existDecimal;
                        String lat = latitude.getText();
                        String dec = decimalPlace.getText();
                        int llength = lat.length();
                        int dlength = dec.length();
                        
                        try{
                                  double string_to_Double = Double.valueOf(lat);
                                  double string_to_DoubleTwo = Double.valueOf(dec);
                        
                    if(string_to_Double <= 90 && string_to_Double >= -90 && string_to_DoubleTwo <= 999999 && string_to_DoubleTwo >= 0)
                    {   
                        firstLatitude = lat;
                        
                        
                        latTrue = true;
                        secondLatitude = dec;
                        myTextArea.append("\n" + "Latitude: " + firstLatitude + "." + secondLatitude + "\n");
                        
                        declatTrue = true;
                        
                        String nothing = "";
                  	    String space = " ";
                  	   outputGeo1 = true;
                        if(nothing.equals(lat) && nothing.equals(dec))
                        	outputGeo1 = false;
                        else if(space.equals(lat.substring(0,1))  &&   space.equals(dec.substring(0,1)))
                        	outputGeo1 = false;
                        
                         
                        }
                        else
                        {
                                myTextArea.append("\n" + "Please type within range" + "\n");
                        }}catch(NumberFormatException e)
                        { 
                     	   myTextArea.append("\n" + "Please type a number" + "\n");
                        }
                }
        }
        
        public class MyPositionTwo  implements ActionListener
        {
                public void actionPerformed(ActionEvent event)
                {
                        String longt = longitudinal.getText();
                        String decTwo = decimalPlaceTwo.getText();
                       try
                       {
                        
                          double string_to_Double = Double.valueOf(longt);
                          double string_to_DoubleTwo = Double.valueOf(decTwo);
                
                          if(string_to_Double <= 180 && string_to_Double >= -180 && string_to_DoubleTwo <= 999999 && string_to_DoubleTwo >= 0)
                          {   
                        	  firstLongitude = longt;
                
                        	  longTrue = true;
                
                        	  secondLongitude = decTwo;
                        	  myTextArea.append("\n" + "Longitude: "  + firstLongitude + "." + secondLongitude + "\n");
                        	  declongTrue = true;
                        	  String nothing = "";
                        	  String space = " ";
                        	  outputGeo2 = true;
                              if(nothing.equals(longt) && nothing.equals(decTwo))
                              	outputGeo2 = false;
                              else if(space.equals(longt.substring(0,1))  &&   space.equals(decTwo.substring(0,1)))
                              	outputGeo2 = false;
                        	  
                
                          }
                          else
                          {
                        myTextArea.append("\n" + "Please type within range" + "\n");
                          }
                       }catch(NumberFormatException e)
                       { 
                    	   myTextArea.append("\n" + "Please type a number" + "\n");
                       }
                }
        }       
        
        public class MyDepositList implements ActionListener   //Deposit Dates, monthTwo, dayTwo, yearTwo
        {
        
                public void actionPerformed(ActionEvent event)
                {   
          JComboBox db = (JComboBox)event.getSource();
                         
          String dataTwo = (String)db.getSelectedItem();
                                         
        //  String cb = monthList.getSelectedItem();
                  if(db.getItemCount() == 12)
                          {  
                             monthTwo = dataTwo;
                                 myTextArea.append("You entered " + "\"" + monthTwo +"\"" + "\n");
                         eMonthTrue = true;       
                          }  
                  if(db.getItemCount() == 31)
                          {  
                              dayTwo = dataTwo;
                                  myTextArea.append("You entered " +"\"" + dayTwo +"\""  + "\n");
                              eDayTrue = true;
                          }
                         if(db.getItemCount() == 32)
                 {  
                              yearTwo = dataTwo; 
                                  myTextArea.append("You entered "  + "\"" + yearTwo + "\""+ "\n");
                          eYearTrue = true;
                         }
            } //end of method
        
        }// end of class MyDepositList
        
        
        public class MyDepositTextAction implements ActionListener
        {
          public void actionPerformed(ActionEvent event)
          {
                JTextField dbt = (JTextField)event.getSource();
                        NumberFormat nf = NumberFormat.getCurrencyInstance();

              if(dbt.getColumns() == 8)
                           {
                                 try
                                 {

                                amountTwo = Double.parseDouble(textFieldOne.getText());

                                        myTextArea.append("Deposit Amount: " + nf.format(amountTwo) + "\n");
                                                
                            }
             catch (Exception z)
                                 {
   
                       myTextArea.append("Deposit Amount needs to be number." + "\n");
                                   textFieldOne.setText("");
                                 }
                 }            

     }
   }
        /*public class MyDepositButton implements ActionListener
        {
          public void actionPerformed(ActionEvent event)
          {
                         NumberFormat nf = NumberFormat.getCurrencyInstance();

                         if(eMonthTrue && eDayTrue && eYearTrue )
                         {
                             eMonthTrue   = false;
                                 eDayTrue     = false; 
                                 eYearTrue    = false;  
                                 
            
        //erase values in textfield when button is clicked
                         
                                 textFieldOne.setText("");                               
                                                                 
                                 storeDepositAmount[buttonDepositNumberCount] = amountTwo;
                                        
                                 storeDepositInformation[buttonDepositNumberCount][1] = monthTwo;
                                 storeDepositInformation[buttonDepositNumberCount][2] = dayTwo;
                                 storeDepositInformation[buttonDepositNumberCount][3] = yearTwo;
                                                                                         
                                 buttonDepositNumberCount++;
                                 
                                myTextArea.append("\n\nYour Deposit Information" + "\n");
                    myTextArea.append(monthTwo + " " + dayTwo + " " + yearTwo + " " + nf.format(amountTwo)  );
                            myTextArea.append( "\n\n" + "If this information is correct, please click on save. " +  "\n"  );
                                         
               }   
                    else
                         {  
                            myTextArea.append("\n\n"+ "You did not enter or clicked on all the fields." + "\n");
                    }
          }
        }
        
*/
public class MySummaryTextField implements ActionListener
{
        public void actionPerformed(ActionEvent event)
        {
                String data = mySummaryArea.getText();
                myTextArea.append("\nYou typed " + data + "\n");
                summaryString = "SUMMARY:" + data.toUpperCase();
                requirementTwo = true;
                
                
        }
        
}

public class MyResourceTextField implements ActionListener
{
        public void actionPerformed(ActionEvent event)
        {
        	    String space =  " ";
        	    String nothing = "";
                String data =  myResourceField.getText();
                myTextArea.append("\nYou typed " + data + "\n");
                resourceString = "RESOURCES:" + data.toUpperCase();
                outputRes = true;
                if(nothing.equals(resourceString))
                	outputRes = false;
                else if(space.equals(resourceString.substring(0,1)))
                	outputRes = false;
                
                
        }
        
}

public class MyLocationTextField implements ActionListener
{
        public void actionPerformed(ActionEvent event)
        {
                String data =  myLocationArea.getText();
                myTextArea.append("\nYou typed " + data + "\n");
                locationString = "LOCATION:" + data.toUpperCase();
                
                requirementFive = true;
                
        }
        
}

public class WriteToFile implements ActionListener
{
        public void actionPerformed(ActionEvent event)
        {
        	         
        	
        	 longitudinal = new JTextField("150"); 
             latitude = new JTextField("-80");
             decimalPlace = new JTextField("123456");
             decimalPlaceTwo = new JTextField("123456");
          /*   
             JComboBox yearList   = new JComboBox(yearString);
             JComboBox monthList  = new JComboBox(monthString);
             JComboBox dayList    = new JComboBox(dayString);
             JComboBox begin_Hour = new JComboBox(beg_Hour); 
         JComboBox begin_Min  = new JComboBox(beg_Min);
         JComboBox begin_AmPm = new JComboBox(beg_AmPm);
         
             ///////END DATE LIST ////////////////////////////
             
             JComboBox yearListTwo   = new JComboBox(yearString);
             JComboBox monthListTwo  = new JComboBox(monthString);
             JComboBox dayListTwo    = new JComboBox(dayString);
             JComboBox begin_HourTwo = new JComboBox(beg_Hour); 
         JComboBox begin_MinTwo  = new JComboBox(beg_Min);
         JComboBox begin_AmPmTwo = new JComboBox(beg_AmPm);
         */
         yearList.updateUI();
         yearListTwo.updateUI();
         begin_Hour.updateUI();
         begin_Min.updateUI();
         begin_AmPm.updateUI();
         begin_HourTwo.updateUI();
         begin_MinTwo.updateUI();
         
         
         
         
         
        	
                if(requirementOne == true && requirementTwo == true && requirementThree == true && requirementFour == true && requirementFive == true)
                {
                        
                         try {
                        	
                                             String filename = "cal.ics";
                                             FileWriter outFile = new FileWriter(filename);
                                             PrintWriter out = new PrintWriter(outFile);
                                             
                                             // Also could be written as follows on one line
                                             // Printwriter out = new PrintWriter(new FileWriter(args[0]));
                                             //reset value
                                             requirementOne   = false;
                                             requirementTwo  = false;
                                             requirementThree = false;
                                             requirementFour = false;
                                             requirementFive = false;
                                             // Write text to file
                                              out.println(beginCal);
                                              out.println(version);
                                              out.println(beginE);
                                              out.println(chosenRadioButton);
                                              out.println(summaryString);
                                              out.println(beginTime);
                                              out.println(endTime);
                                              if(outputGeo1 && outputGeo2 && !(totalPosition.equals("GEO:")))
                                              {
                                            	  out.println(totalPosition);
                                            	  outputGeo1    = false;
                                            	  outputGeo2    = false;
                                              }
                                              out.println(locationString);
                                              if(outputRes && !(resourceString.equals("RESOURCES:")))
                                              {  
                                              out.println(resourceString);
                                                outputRes     = false;
                                              }
                                              if(outputComment && !(storeComment.equals("COMMENT:")))
                                              {
                                            	  out.println(storeComment);
                                                   
                                            	  outputComment = false;
                                              }
                                              out.println(endE);
                                              out.println(endCal);
                                              out.close();
                                             
                                              
                                              
                                              
                                              
                                              
                                          } catch (IOException e)
                                            {
                                             e.printStackTrace();
                                            }
                        
                        
                         myTextArea.append("\nFile is Successfully Written, Thank You Very Much!  \n");
                        
                        
                }
                else
                        myTextArea.append("\n\nRequirements not fulfilled, I am sorry we cannot write to file. please try again." + "\n");
                
        }
}



        
 public class MyEraseTextField implements ActionListener
        {               
                public void actionPerformed(ActionEvent event)
      {
                   int removeCheckCount = 0;
                   try 
                        { 
                                removeCheckNumber = Integer.parseInt(field.getText());
                            myTextArea.append("\nRemove Check entered " + "\"" + removeCheckNumber + "\"\n");
                                
                                for(int i = 0; i < buttonCheckNumberCount; i++)
                        {
                           if(removeCheckNumber == storeCheckNumber[i])
                               {    
                                           removeCount = i;
                                           removeTrue = true;
                                   }      
                            }
                   }
                   catch (Exception z) 
                   {               
                                myTextArea.append("\n" + "Check Number needs to be an integer." + "\n");                                        
                                field.setText(""); 
                return;   
           }    
                }//end of method
        }  //end of class
 
 
 public class MyRadioButtonAction implements ActionListener
 {
         public void actionPerformed(ActionEvent event)
         {
                 Object source = event.getSource();
                 radioButton = null; 
                 requirementOne = true;
                 
                 if(source == publicRButton)
                 { 
                         radioButton = "public";
                         myTextArea.append("\n"+ "Radio button entered \"" + radioButton +  "\"\n");
                         chosenRadioButton = "CLASS:PUBLIC";
                 }
                 if(source == privateRButton)
                 {
                         radioButton = "private";
                         myTextArea.append("\n"+ "Radio button entered \"" + radioButton + "\"\n");
                         chosenRadioButton = "CLASS:PRIVATE";
                 }
                 if(source == confidentialRButton)
                 {
                         radioButton = "confidential";
                         myTextArea.append("\n"+ "Radio button entered \"" + radioButton + "\"\n");
                         chosenRadioButton = "CLASS:CONFIDENTIAL";
                 }
                         
                 
         }
         
         
 }
 
  public class CommentButtonAction implements ActionListener
        {               
         
                public void actionPerformed(ActionEvent event)
                {
                        String nothing = "";
                        String space = " ";
                        String data = myCommentArea.getText();
                        myTextArea.append("\nYou typed: " + data + "\n"  );                                     
                        storeComment = "COMMENT:" +  data.toUpperCase();
                        outputComment = true;
                        if(nothing.equals(storeComment))
                        	outputComment = false;
                        else if(space.equals(storeComment.substring(0,1)))
                        	outputComment = false;
                        		
                    }

        }

  public class MyResultButtonAction implements ActionListener
        {               
                public void actionPerformed(ActionEvent event)   //THREE BUTTONS, CHECK HISTORY, CHECK BALANCE, DEPOSIT HISTORY
      {
                  NumberFormat nf = NumberFormat.getCurrencyInstance();

                  if(event.getSource() == buttonOne )
                    {     myTextArea.append("\n\n" + "" +"\n\n");
                          myTextArea.append(beginCal+"\n");
                          myTextArea.append(version + "\n");
                          
                          myTextArea.append(beginE + "\n");
                          myTextArea.append(chosenRadioButton + "\n");
                          myTextArea.append(summaryString + "\n");
                /*        if(flagForTimeZoneOne == true && flagForTimeZoneTwo == true)
                          {
                                  Date now = new Date();
                                  
                                                    SimpleDateFormat  format = new SimpleDateFormat("z"); 
                                                        String newF = format.format(now);
                                                        timeZone = "ZONE: " + newF;
                                  myTextArea.append(timeZone + "\n");
                          }*/
                          
                          myTextArea.append(beginTime + "\n");
                          myTextArea.append(endTime + "\n");
                          if(longTrue == true && declongTrue == true && latTrue == true && declatTrue == true)
                          {  
                                  totalPosition = "GEO:" + firstLatitude + "." + secondLatitude +";" + firstLongitude + "." + secondLongitude;
                                  
                                  myTextArea.append(totalPosition + "\n");
                                 
                                  longTrue =  false;
                                  declongTrue = false;
                                  latTrue = false; 
                                  declatTrue = false;
                          
                                  
                          }
                          else
                                  myTextArea.append(totalPosition + "\n");
                                  
                          
                          myTextArea.append(locationString + "\n");
                          myTextArea.append(resourceString + "\n");
                          myTextArea.append(storeComment + "\n");
                          myTextArea.append(endE + "\n");
                          myTextArea.append(endCal + "\n");
                        
                
                   }    
                }// end of action method
        }//end of MyResultButtonAction
  
     public class MySaveButtonAction implements ActionListener
         {              
                public void actionPerformed(ActionEvent event)   //THREE BUTTONS, CHECK HISTORY, CHECK BALANCE, DEPOSIT HISTORY
        {    
                         if(event.getSource() == helpButton )
                          {
                              myTextArea.append("\n\n\t\tThank you for using our easy to use My Check Book Program 1.0.\n");
                                  myTextArea.append("\n\nJust a few things to mention.\n");
                                  myTextArea.append("\n1) Every data entered gives a visual confirmation.");
                                  myTextArea.append("\n    a) Click every listed option or press keyboard enter after every field typed in");
                                  myTextArea.append("\n    b) When all fields are placed, click the enter button.");
                                  myTextArea.append("\n\n2) Only the button\"Save\" will save both deposit and check information.");
                                  myTextArea.append("\n    a) Each function's enter button will not save the information");
                                  myTextArea.append("\n\n Add/Subtract Deposit Information");
                                  myTextArea.append("\n1) In the case you add too much money, simply subtract the extra amount.");
                                  myTextArea.append("\n    a) For example, enter -300 ");
                                  myTextArea.append("\n\n Remove Check Information");
                                  myTextArea.append("\n1) Type in the check number, press enter on your keyboard, finally click the remove button");
                          }      
                         if(event.getSource() == exitButton )
               System.exit(0);
                          
                          if(event.getSource() == saveButton )
                          {
                            myTextArea.append("\nYour Check and Deposit Informations are saved.\n");
                        
                                        
                                
                   try 
                         {
                      // Create an output stream to the file.
                        FileOutputStream file_output = new FileOutputStream (file);
                   // Wrap the FileOutputStream with a DataOutputStream
                DataOutputStream data_out = new DataOutputStream (file_output);
            // Write the data to the file in an integer/double pair
    
                    data_out.writeDouble(totalCheckAmount);             
                                                                 
                data_out.writeInt (buttonCheckNumberCount);
                         
                        for (int i=0; i < buttonCheckNumberCount; i++) 
                        {
                                data_out.writeInt (storeCheckNumber[i]);
                                data_out.writeUTF (storeCheckInformation[i][1]);
                                data_out.writeUTF (storeCheckInformation[i][2]);
                                data_out.writeUTF (storeCheckInformation[i][3]);
                                data_out.writeUTF (storeCheckInformation[i][4]);
                                data_out.writeDouble (storeCheckAmount[i]);
                        }
                         // Close file when finished with it..
                        file_output.close ();

                    }
                 catch (IOException e) 
                        {
                                myTextArea.append("IO exception = " + e );
                        }
                 
                 try 
                        {
                     // Create an output stream to the file.
                       FileOutputStream file_output2 = new FileOutputStream (fileTwo);
                  // Wrap the FileOutputStream with a DataOutputStream
               DataOutputStream data_out = new DataOutputStream (file_output2);
           // Write the data to the file in an integer/double pair
               data_out.writeDouble(totalDepositAmount);
                         // data_out.writeUTF (name);
               data_out.writeInt (buttonDepositNumberCount);
                         // data_out.writeDouble(totalDepAmt);
 
               for (int j=0; j < buttonDepositNumberCount; j++) 
               {
                   data_out.writeUTF (storeDepositInformation[j][1]);
                   data_out.writeUTF (storeDepositInformation[j][2]);
                   data_out.writeUTF (storeDepositInformation[j][3]);
                   data_out.writeDouble (storeDepositAmount[j]);
               }
      // Close file when finished with it..
               file_output2.close ();

                  }
                 catch (IOException e) 
                 {
                         myTextArea.append("IO exception = " + e );
         }

           
           }//end of if statement (check file)
        

           
 
        }// end of method
                
        }// end of MySaveButtonAction

     public String getDtstart()
     {
    	 
    	 return beginTime; 
    	 
     }
     
     public String endTime()
     {
    	 
    	 return endTime;
     }
     public String getPriority()
     {
    	 return chosenRadioButton;
     }
     public String getComment()
     {
    	 return storeComment;
     }
     
  
    
     
}//end of Interact class
